from COG_CheckJob import COG_CheckJob
from COG_OptimalJob import COG_OptimalJob
import sys,time
import os
def main(type,tmpl_no,cog_dest):

    table_1 = []
    try:
        type = int(type)
        tmpl_no = tmpl_no
        cog_dest = cog_dest
        success = True
    except Exception as e:
        success = False
        msg = f'invalid_parameter_type--{str(e)}'
        timestamp = None
    if success:
        try:
            if type == 1.0:
                message, result_list = COG_CheckJob(p_tmpl_no=tmpl_no, p_cog_dest=cog_dest).execute()
            elif type == 0.0:
                message = COG_OptimalJob(p_tmpl_no=tmpl_no, p_cog_dest=cog_dest).execute()
                result_list = []
            timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
            success = True
            if message == '求不出最优方案':
                success = False
            msg = message
            table_1 = result_list
        except Exception as e:
            success = False
            msg = f'run_model_job_failed---with--{str(e)}'
            timestamp = None
        # if type == 1.0:
        #     message, result_list = CheckJob(p_tmpl_no=tmpl_no, p_price_sql=price_sql).execute()
        # elif type == 0.0:
        #     message = OptimalJob(p_tmpl_no=tmpl_no, p_price_sql=price_sql).execute()
        #     result_list = []
        # timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        # success = True
        # msg = message
        # table_1 = result_list

    success = success
    message = msg
    timestamp = timestamp
    table_1 = table_1
    return success,message,timestamp,table_1







if __name__ == '__main__':
    success,message,timestamp,table_1= main(type=0,tmpl_no='TM202308181451',cog_dest='')
    print(success,message,timestamp,table_1)